<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title>添加个人公司信息</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-win.css">
<style type="text/css">
	*{
		margin: 0;
		padding:0;
	}
	body{
		width: 100%;
		height: 100%;
		position: relative;
	}
		.header{
			height: 45px;
			width: 100%;
			background: #00abfd;
			line-height: 45px;
			text-align: center;
			color: white;
			font-weight: bold;
			font-size: 1.5rem;
		}
		#ul{
			width: 100%;
		}
		#ul li{
			height: 40px;
			width: 90%;
			list-style: none;
			margin: 10px 0 0 5%;
		}
		#ul li p{
			height: 40px;
			width: 32%;
			float: left;
			line-height: 40px;
		}
		#ul li input{
			height: 30px;
			width: 55%;
			float: left;
			margin-top: 4px;
			padding-right: 20px;
			border-bottom:1px solid #999;
			line-height: 20px;
			padding-left: 5px;
			background: none;
		}
		#ul li select{
			width: 63%;
			float: left;
			height: 23px;
			margin-top: 8px;
			background: none;
		}
		#ul textarea{
			width: 80%;
			height: 140px;
			margin-left: 5%;
			margin-top: 10px;
			padding:10px 5% 10px 5%; 
			border:1px solid #ccc;
			background: white;
		}
		#ul .li1 input{
			height: 40px;
			width: 100%;
			border: none;
			border-radius: 6px;
			color: white;
			background: #00abfd;
		}
		#ul .li1{
			margin-bottom: 10px;
			height: 45px;
		}
		.tanchu{
			width: 100%;
			height: 100%;
			background: black;
			position: absolute;
			opacity: 0.5;
			display: none;
		}
		.tanchukuang{
			width: 70%;
			height: 150px;
			background: white;
			position: absolute;
			z-index: 666;
			top: 50%;
			left: 50%;
			margin-left: -35%;
			margin-top: -50%;
			display: none;
		}
		.tanchukuang input{
			width: 100%;
			height: 40px;
			background: #ccc;
			border: none;
			color: 1rem;
		}
		.tanchukuang p{
			width: 100%;
			height: 110px;
			text-align:center;
			line-height: 110px;
		}
		#ul #myheadimg{
			margin-top:8px;
		}
		.main{
		position:fixed;
		top:45px;
		width:100%;
		overflow:scroll;
		height:100%;
	}
	</style>
</head>
<body>
	<div class="tanchu" id="tanchu">
		
	</div>
	<div class="tanchukuang">
			<p class="content"></p>
			<input type="button" value="确定" onclick="content()">
	</div>
	<header class="aui-bar aui-bar-nav aui-bar-yunzo" id="aui-header">
		<a class="aui-btn aui-bar-yunzo aui-pull-left" id="back" onclick="back_go()"> <span class="aui-iconfont aui-icon-left"></span></a>
		<div class="aui-title" id="title">
			添加个人公司信息
		</div>
		<a class="aui-iconfont aui-icon-menu aui-pull-right"></a>
	</header>
	<div class="margin_div"></div>
	<article class="main"  id="wrapper">
	<ul id="ul">
		<li><p class="text_p">公司名称：</p><input type="text" id="namee" placeholder="长度不能超过15位汉字"></li>
		<li><p class="text_p">担任职务：</p>
			<select id="comduty">
				
			</select>
		</li>
		<li><p class="text_p">公司性质：</p>
			<select id="comproperty">
				
			</select>
		</li>
		<li><p class="text_p">公司规模：</p>
			<select id="comscale">
				
			</select>
		</li>
		<li><p class="text_p">所属行业：</p>
			<select id="comindustry">

			</select>
		</li>
		<li><p class="text_p">联系电话：</p><input type="text" id="comtellphone" placeholder="有效手机号、座机号"></li>
		<li><p class="text_p">公司emali：</p><input type="text" id="comemail" placeholder="正确格式 xxx@xx.com"></li>
		<li><p class="text_p">公司地址：</p><input type="text" id="comaddress" placeholder="长度不能超过20位汉字"></li>
		<li><p class="text_p">公司网址：</p><input type="text" id="comurl" placeholder="正确格式 www.xxxxx.com"></li>
		<li><p class="text_p">电商网址：</p><input type="text" id="comecurl" placeholder="填写淘宝，京东等电商店网址或者贵公司电商网址"></li>
		<!--<li><p class="text_p">公司Logo：</p><input type="file" id="myheadimg" accept="image/*;capture=camera" name="myheadimg" style="border: none;"></li>-->
		<textarea  placeholder="这里输入对您公司的描述信息：(公司信息长度不能少于10个汉字)" id="comment"></textarea>
		<li class="li1"><input type="button" value="确定添加" id="submit"></li>
	</ul>
	<div class="margin_div"></div>
	</article>
	<script type="text/javascript" src="../../script/jquery-1.10.2.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript">
			
	var a;
	var str_comindustry="";
	var str_comduty="";
	var str_comproperty="";
	var str_comscale="";
	for(var i=0;i<arr_industry.length;i++){
		str_comindustry+="<option>"+arr_industry[i]+"</option>"
	}
	$("#comindustry").html(str_comindustry);
	for(var i=0;i<arr_comduty.length;i++){
		str_comduty+="<option>"+arr_comduty[i]+"</option>"
	}
	$("#comduty").html(str_comduty);
	for(var i=0;i<arr_comproperty.length;i++){
		str_comproperty+="<option>"+arr_comproperty[i]+"</option>"
	}
	$("#comproperty").html(str_comproperty);
	for(var i=0;i<arr_comscale.length;i++){
		str_comscale+="<option>"+arr_comscale[i]+"</option>"
	}
	$("#comscale").html(str_comscale);
	/*--正则判断--*/
	$("#namee").blur(function(){
		if($("#namee").val()!=""&&$("#namee").val().length<=15){
			a=true;
			$("#namee").css("background","url(../../image/my/dui.png)")
			$("#namee").css("background-repeat","no-repeat");
			$("#namee").css("background-position","100% 0");
		}
		else{
			a=false;
			$("#comName").css("background","url(../../image/my/cuo.png)")
			$("#comName").css("background-repeat","no-repeat");
			$("#comName").css("background-position","100% 0");
		}
	})
	/*-----------------以上部分验证公司名称----------------------------*/
	$("#comtellphone").blur(function(){
		var re=/^[0-9]{10,12}$/;
		if(re.test($("#comtellphone").val())!=false){
			a=true;
			$("#comtellphone").css("background","url(../../image/my/dui.png)")
			$("#comtellphone").css("background-repeat","no-repeat");
			$("#comtellphone").css("background-position","100% 0");
		}
		else if($("#comtellphone").val()==""){
			a=true;
			$("#comtellphone").css("background","none")
		}
		else{
			a=false;
			$("#comtellphone").css("background","url(../../image/my/cuo.png)")
			$("#comtellphone").css("background-repeat","no-repeat");
			$("#comtellphone").css("background-position","100% 0");
		}
	})
	/*----------------------以上部分验证电话------------------------*/
	$("#comemail").blur(function(){

		var re=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if(re.test($("#comemail").val())!=false){
			a=true;
			$("#comemail").css("background","url(../../image/my/dui.png)")
			$("#comemail").css("background-repeat","no-repeat");
			$("#comemail").css("background-position","100% 0");
		}
		else if($("#comemail").val()==""){
			a=true;
			$("#comemail").css("background","none")
		}
		else{
			a=false;
			$("#comemail").css("background","url(../../image/my/cuo.png)")
			$("#comemail").css("background-repeat","no-repeat");
			$("#comemail").css("background-position","100% 0");
		}
	})
	/*--------------------以上验证邮箱---------------------------*/
	$("#comaddress").blur(function(){
		if($("#comaddress").val().length<=20&&$("#comaddress").val()!=""){
			a=true;
			$("#comaddress").css("background","url(../../image/my/dui.png)");
			$("#comaddress").css("background-repeat","no-repeat");
			$("#comaddress").css("background-position","100% 0");
		}
		else if($("#comaddress").val()==""){
			$("#comaddress").css("background","none")
		}
		else{
			a=false;
			$("#comaddress").css("background","url(../../image/my/cuo.png)")
			$("#comaddress").css("background-repeat","no-repeat");
			$("#comaddress").css("background-position","100% 0");
		}
	})
	/*--------------------------以上验证公司地址----------------------------*/
	$("#comment").blur(function(){

		if($("#comment").val().length>=10){
			a=true;
			$("#comment").css("background","url(../../image/my/dui.png)")
			$("#comment").css("background-repeat","no-repeat");
			$("#comment").css("background-position","100% 0");
		}
		else if($("#comment").val()==""){
			$("#comment").css("background","none")
			a=true;
		}
		else{
			a=false;
			$("#comment").css("background","url(../../image/my/cuo.png)")
			$("#comment").css("background-repeat","no-repeat");
			$("#comment").css("background-position","100% 0");
		}
	})
	/*--正则判断结束--*/
		$("#submit").click(function(){
			uploadComplete();
			/*var bodyparam={
            	"mid":$mid,
            	"groupid":$groupid,
            	"did":initdata.get('mycompany'),
            	"comlogo":comlogo,
            	"comname":comName,
            	"comduty":comduty,
            	"comproperty":comproperty,
            	"comscale":comscale,
            	"comindustry":comindustry,
            	"comtellphone":comtellphone,
            	"comemail":comemail,
            	"comaddress":comaddress,
            	"comurl":comurl,
            	"comment":comment,
            	"togroupid":togroupid,
            	"togroupname":groupname,
            	"comid":comid
        	};
        	if(a==true){
        	ajaxCoCRequest("../../../api/account/addmycompanyinfo","POST",bodyparam,function(msg){
            	if(msg.code==100){
            		alert("添加成功")
            		window.location = "mycompany_list.html";
            	}
            	else{
            		alert(JSON.stringify(msg)) 
            	}
        	});
        	}
        	else{
        		$(".tanchu").css("display","block");
        		$(".tanchukuang").css("display","block");
        		$(".content").html("您输入的内容有误");

        	}*/

        	//uploadFile();
		})
		var tanchu=document.getElementById("tanchu");
		var ch1=document.documentElement.clientHeight;
		tanchu.style.height=ch1+"px";
		function content(){
			$(".tanchu").css("display","none");
        	$(".tanchukuang").css("display","none");
		}
/*------------------------------------文件上传--------------------------------------*/
/*$("#myheadimg").change(function(){
    	fileSelected();
    });
 function fileSelected() {
        var file = document.getElementById('myheadimg').files[0];
        if (file) {
        	var url=getObjectURL(file);
        }
      }
 function uploadFile() {
        var fd = new FormData();
    //    fd.append("myheadimg", document.getElementById('myheadimg').files[0]);
        var xhr = new XMLHttpRequest();
       	xhr.upload.addEventListener("progress", uploadProgress, false);
        xhr.addEventListener("load", uploadComplete, false);
        xhr.addEventListener("error", uploadFailed, false);
        xhr.addEventListener("abort", uploadCanceled, false);
        xhr.open("POST", "../../../api/file/upload");
        xhr.send(fd);
      }

      function uploadProgress(evt) {
        if (evt.lengthComputable) {
          var percentComplete = Math.round(evt.loaded * 100 / evt.total);
          //document.getElementById('progressNumber').innerHTML = percentComplete.toString() + '%';
        }
        else {
        //  document.getElementById('progressNumber').innerHTML = 'unable to compute';
        }
      }
*/
      function uploadComplete(/*evt*/) {
      	var comName=$("#namee").val();
			var comduty=$("#comduty").val();
			var comproperty=$("#comproperty").val();
			var comscale=$("#comscale").val();
			var comindustry=$("#comindustry").val();
			var comtellphone=$("#comtellphone").val();
			var comemail=$("#comemail").val();
			var comaddress=$("#comaddress").val();
			var comurl=$("#comurl").val();
			var comecurl=$("#comecurl").val();//淘宝店地址
			var comment=$("#comment").val();
			var togroupid=$groupid;
			var groupname=$groupname;
			var comlogo;
			var comid="null";
			
    	//  var obj = JSON.parse(evt.target.responseText);
    	/* if($("#myheadimg").val()!=""){
    	 	comlogo=obj.datum.myheadimg
    	 }*/
    	 var bodyParam={
  	            "mid":$mid,
            	"groupid":$groupid,
            	"did":initdata.get('mycompany'),
            	"comlogo":comlogo,
            	"comname":comName,
            	"comduty":comduty,
            	"comproperty":comproperty,
            	"comscale":comscale,
            	"comindustry":comindustry,
            	"comtellphone":comtellphone,
            	"comemail":comemail,
            	"comaddress":comaddress,
            	"comurl":comurl,
            	"comecurl":comecurl,
            	"comment":comment,
            	"togroupid":togroupid,
            	"togroupname":groupname,
            	"comid":comid
  	        };
             ajaxCoCRequest("../../../api/account/addmycompanyinfo", "POST", bodyParam, function(msg){
                 if(msg.code==100){
            		window.location = "mycompany_list.html";
                 }else{
                	 $("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
                 }
                
             });
      }

 /*     function uploadFailed(evt) {
    	  alert("图片上传失败,请重新选择图片!");
      }

      function uploadCanceled(evt) {
        alert("上传已经取消,请重新选择图片!");
      }
/*function getObjectURL(file) {
      	var url = null ; 
      	if (window.createObjectURL!=undefined) { // basic
      		url = window.createObjectURL(file) ;
      	} else if (window.URL!=undefined) { // mozilla(firefox)
      		url = window.URL.createObjectURL(file) ;
      	} else if (window.webkitURL!=undefined) { // webkit or chrome
      		url = window.webkitURL.createObjectURL(file) ;
      	}
      	return url ;
      }*/
	</script>
</body>
</html>